package core.collection.mymap;

import core.collection.bean.Student;

import java.util.HashMap;

/**
 * @author
 * @create 2018-12-23 12:03
 **/
public class mymap_3_Map_HashMap {
    public static void main(String[] args) {
        demo_hashMap();
    }

    /*
     * * A:案例演示
     * HashMap集合键是Student值是String的案例
     * 键是学生对象,代表每一个学生
     * 值是字符串对象,代表学生归属地
     */
    public static void demo_hashMap(){
        HashMap<Student, String> hm = new HashMap<>();
        hm.put(new Student("张三", 23), "北京");
        hm.put(new Student("张三", 23), "上海");
        hm.put(new Student("李四", 24), "广州");
        hm.put(new Student("王五", 25), "深圳");

        System.out.println(hm);

        //所以注意要在student中重写hashcode和equals方法
    }
}
